<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

use think\Db;
use think\Session;


function datetime($time,$day){
	
	$tm=date("Y-m-d H:i:s",strtotime($time." + ".$day."day"));;
return $tm;
}
function vehicle_label($type){//状态
  if($type=='1'){
   return "<font class='pub_btn' > 开启中</font>";
  }else{
	  return "<font color='red'>关闭中</font>";
  }

}
//充值返点
function rechargefd($money,$id,$confbl,$fool='0',$username=''){
    if($fool>2){return ;}//2及返回
    $userid=$id;
    $arr=explode(',',$confbl);
    if(empty($arr[$fool])){return ;}//未设置比例结束
    $user=Db::name('member')->field('inviter')->where('id',$userid)->find();
    if(empty($user['inviter'])){return;}//没有推荐人就结束
    else{
        $moneyf=$money*$arr[$fool]/100; $fool++;
        handlelog($user['inviter'],$moneyf,'+',2,'会员-'.$username.'充值返点');
        $con='您的下级会员-'.$username.'充值了'.$money.'元,收益分成为'.$moneyf.'元';
        addnews('充值返点',$con,$user['inviter']);
        rechargefd($money,$user['inviter'],$confbl,$fool,$username);
    }
}


function cztc($id,$money){

	$user=Db::name('member')->where('id',$id)->find();
	if($user['inviter']!=''){

	$usersj=Db::name('member')->where('id',$user['inviter'])->find();
	if($usersj){
	      $config= Db::name('config')->find();
				  $cztcbl=$config['cztc'];
				  $mon=$money*$cztcbl/100;
				  $inc=Db::name('member')->where('id',$usersj['id'])->setInc('amount',$mon);//添加金额
				  if($inc){ addmoneylog($usersj['id'],'下级会员:'.$user['name'].',充值成功提成，添加金额！',$mon,'+');//添加金额记录
				  }

	   }
	}

}
function projectstatus($type){//状态
  if($type=='1'){
   return "<span class='red'>[已投满]          </span>";
  }else{
	  return "<font color=' green'>[投资中]</font>";
  }

}

function projectsfhg($type){//回购状态
  if($type=='1'){
   return "<span class='red'>[溢价回购]          </span>";
  }else{
	  return "<font color='green'>[正常完成]</font>";
  }

}



